package com.avic.modules.predict;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @program: ehs
 * @ClassName Recommend
 * @author: ayetony miao
 * @create: 2023-10-27 11:33
 **/
@Service
public class Recommend {

    @Value("${predict.serve}")
    private String serve;

    public static void test() {
        PredictParam param = new PredictParam();
        param.setFunc_name(PredictionEnum.FLATTAIL.getAction());
        param.setNumber(1);
        String body = HttpUtil.createPost("http://192.168.2.29:9000/data_service")
                .contentType("application/json")
                .body(JSONUtil.toJsonStr(param)).execute().body();
        System.out.println(body);
    }

    public MessageDto executeAction(PredictParam param) {
        String body = HttpUtil.createPost(serve)
                .contentType("application/json")
                .body(JSONUtil.toJsonStr(param)).execute().body();
        return JSONUtil.toBean(body, MessageDto.class);
    }

}
